﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WCFService;
using Database;

namespace DataAccessLayer
{
    public class SubForumData
    {
        public int ForumID { get; set; }
        public int ID { get; set; }
        public String Title { get; set; }
        //public String Manager { get; set; }
    }

    public class ForumDataLayer
    {
        public static List<SubForumData> GetForumData(int forumID)
        {
            List<SubForumData> fdList = new List<SubForumData>();

            AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
            LogicForumImp forumManager = new LogicForumImp();
            Forum forumDataObj = forumManager.getForum(null, forumID);

            SortedDictionary<int, SubForum> subForums = forumDataObj.getSubForums();

            foreach (SubForum sf in subForums.Values)
            {
                fdList.Add(new SubForumData {ForumID = forumDataObj.getId(), ID = sf.getId(), Title = sf.getTitle() });
            }

            return fdList;
        }

        public static List<String> GetForumDetails(int forumID)
        {
            AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
            LogicForumImp forumManager = new LogicForumImp();
            Forum forum = forumManager.getForum(null, forumID);
            List<String> forumDetails = new List<String>();
            forumDetails.Add(forum.getTitle());
            forumDetails.Add(forum.getAdmin().getUserName());
            return forumDetails;
        }
    }
}